#pragma once

#include <atlddx.h>
#include <atlcrack.h>

class CIpConfigDlg : public CDialogImpl<CIpConfigDlg>,
	public CWinDataExchange<CIpConfigDlg>
{

public:
	CIpConfigDlg(void);
	~CIpConfigDlg(void);

protected:
	CIPAddressCtrl acStart;
	CIPAddressCtrl acEnd;
	CIPAddressCtrl acServer;
	CIPAddressCtrl acNetmask;
	CIPAddressCtrl acGateWay;
	CIPAddressCtrl acDns1;
	CIPAddressCtrl acDns2;
	CListViewCtrl ips;

	IPInformationDat  dat;
	UINT dwRentTime;

	int  m_nItem;

	CRoomDataMgr  m_roomDataMgr;

public:

	enum { IDD = IDD_DLG_IP_CONFIG };

	BEGIN_MSG_MAP(CIpConfigDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
		COMMAND_HANDLER_EX(IDC_BTN_CANCEL, BN_CLICKED, OnBtnCancelBnClicked)
		COMMAND_HANDLER_EX(IDC_BTN_OK, BN_CLICKED, OnBtnOkBnClicked)
		COMMAND_HANDLER_EX(IDC_BTN_DEFAULT, BN_CLICKED, OnBtnDefaultBnClicked)
		
		COMMAND_HANDLER_EX(IDC_BTN_RESET, BN_CLICKED, OnBtnResetBnClicked)		
		COMMAND_HANDLER_EX(IDC_BTN_SAVE, BN_CLICKED, OnBtnSaveBnClicked)
		NOTIFY_HANDLER_EX(IDC_LIST1, LVN_ITEMCHANGED, OnList1LvnItemChanged)
		
		COMMAND_HANDLER(IDC_BTN_EXPORT, BN_CLICKED, OnBnClickedBtnExport)
	END_MSG_MAP()

	BEGIN_DDX_MAP(CIpConfigDlg)
		DDX_UINT(IDC_EDIT1, dwRentTime)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS1, acStart)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS2, acEnd)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS3, acNext)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS5, acNetmask)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS4, acGateWay)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS6, acDns1)
	//	DDX_CONTROL_HANDLE(IDC_IPADDRESS7, acDns2)
	//	DDX_CONTROL_HANDLE(IDC_LIST1, ips)
	END_DDX_MAP()


	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	

	LRESULT OnBtnCancelBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
	LRESULT OnBtnOkBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);

	LRESULT OnBtnDefaultBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);

	int LoadConfig(void);
	int SaveConfig(void);
	int ResetConfig(void);
	int ShowConfig(void);

	int ResetDlgText(void);

	LRESULT OnBtnResetBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
	LRESULT OnList1LvnItemChanged(LPNMHDR pnmh);
	int ShowItemDetail(int nItem);
	LRESULT OnBtnSaveBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
	
	LRESULT OnBnClickedBtnExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
};
